package com.baichang.taoshunda.dao.impl;

import com.baichang.framework.dao.impl.BaseDaoImpl;
import com.baichang.framework.model.Page;
import com.baichang.taoshunda.dao.IncidentalDao;
import com.baichang.taoshunda.entity.Incidental;
import org.springframework.stereotype.Repository;

/**
 * Created by ${wushenglu} on 2018/3/22.
 */
@Repository
public class IncidentalDaoImpl extends BaseDaoImpl<Incidental> implements IncidentalDao {

    /**
     * @param type
     * @param nowPage
     * @param pageSize
     * @return
     */
    @Override
    public Page queryVideo(Integer type, int nowPage, int pageSize) {
        String sql = "SELECT ic.*,IFNULL(g.`name`,t.host_name) AS  allName FROM t_incidental ic " +
                "LEFT  JOIN t_goods  g ON g.id =ic.all_id AND ic.type=1 " +
                "LEFT  JOIN t_trends  t ON t.id =ic.all_id AND ic.type=2 ";
        if (type > 0) {
            sql += " WHERE ic.type=?";
            return pageForMapList(sql, nowPage, pageSize, type);
        }
        return pageForMapList(sql, nowPage, pageSize);
    }
}
